package xjtu.se.articlecommunity.admin.login.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import xjtu.se.articlecommunity.admin.login.dto.Admin;
import xjtu.se.articlecommunity.admin.login.dto.Mail;
import xjtu.se.articlecommunity.admin.login.dto.Tel;

@Mapper
public interface AdminLoginDao {
    @Select("select count(*) from t_user where u_id = #{u_id} " +
            "and u_passwd = #{u_pwd}" +
            "and u_role = 2")
    int loginByPwd(Admin admin);

    @Select("select count(*)  from t_user where u_mail = #{u_mail} " +
            "and u_role = 2")
    int checkMail(@Param("u_mail") String mail);

    @Select("select u_id, u_passwd as u_pwd from t_user where u_mail = #{u_mail} " +
            "and u_role = 2")
    Admin getInfoByMail(Mail mail);

    @Select("select count(*) from t_user where u_tel = #{u_tel} " +
            "and u_role = 2")
    boolean checkTel(@Param("u_tel") String tel);

    @Select("select u_id, u_passwd as u_pwd from t_user where u_tel = #{u_tel} " +
            "and u_role = 2")
    Admin getInfoByTel(Tel tel);


}
